﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace POVRay {
    public struct Vector2 {
        public float X, Y;

        public Vector2(float x, float y) {
            this.X = x;
            this.Y = y;
        }

        public static Vector2 operator -(Vector2 v) {
            return new Vector2(-v.X, -v.Y);
        }

        public static Vector2 operator +(Vector2 v1, Vector2 v2) {
            return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
        }

        public static Vector2 operator -(Vector2 v1, Vector2 v2) {
            return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
        }

        public static Vector2 operator *(Vector2 v, float scale) {
            return new Vector2(v.X * scale, v.Y * scale);
        }

        public static float Distance(Vector2 v1, Vector2 v2) {
            float dx = v1.X - v2.X;
            float dy = v1.Y - v2.Y;
            return (float)Math.Sqrt(dx * dx + dy * dy);
        }

        public static void Distance(ref Vector2 v1, ref Vector2 v2, out float result) {
            float dx = v1.X - v2.X;
            float dy = v1.Y - v2.Y;
            result = (float)Math.Sqrt(dx * dx + dy * dy);
        }

        public override string ToString() {
            return "<" + X.POVRayString() + ", " + Y.POVRayString() + ">";
        }
    }
}
